Convert complex numerical array to associative array [PHP]

Posted by user1500412 on Stack Overflow See other posts from Stack Overflow or by user1500412
Published on 2012-11-09T04:25:42Z Indexed on 2012/11/09 5:00 UTC
Read the original article Hit count: 111

I have an array data that look like this :

Array (
    [0] => Array (
        [0] => Name:
        [1] => John W.
        [2] => Registration ID:
        [3] => 36
    ) 
    [1] => Array (
        [0] =>Age:
        [1] => 35
        [2] => Height:
        [3] => 5'11"
    ) 
    [3] => Array (
        [0] => Sex:
        [1] => M
        [2] => Weight:
        [3] => 200lbs
    )
    [4] => Array (
        [0] => Address
    )
    [5] => Array (
        [0] => 6824 crestwood dr delphi, IN 46923
    ))

And I want to convert it to associative array like this :

Array(
    ['Name']=> John W.
    ['Registration ID']=> 36
    ['Age']=> 35
    ['Height'] => 5'11''
    ['Sex']=>M
    ['Weight']=>200lbs
    ['Address']=>6824 crestwood dr delphi, IN 46923
)

I have no idea at all how to do this, since the supposed to be array column header were also in sequence, so it makes difficult to convert this array.

Any help I appreciate, thx.

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays